package structure.proxy.dynamicproxy.cglib;

import net.sf.cglib.proxy.MethodInterceptor;
import net.sf.cglib.proxy.MethodProxy;

import java.lang.reflect.Method;

public class CglibTest implements MethodInterceptor {
    @Override
    public Object intercept(Object o, Method method, Object[] objects, MethodProxy methodProxy) throws Throwable {
        System.out.println("cglib代理类 调用前");
        Object result = methodProxy.invokeSuper(o, objects);
        System.out.println("cglib代理类 调用后");
        return result;
    }

    public Object getProxy(Class cla) {
        return net.sf.cglib.proxy.Enhancer.create(cla, this);
    }
}
